<x-filament-panels::page>
    {{ $this->content }}

    <div x-data="{ allExpanded: false}" class="space-x-4">
        <x-filament::button x-show="!allExpanded" color="gray"  x-on:click="$dispatch('expand-all'); allExpanded = true">
            展开
        </x-filament::button>
        <x-filament::button x-show="allExpanded" color="gray"  x-on:click="$dispatch('collapse-all'); allExpanded = false">
            折叠
        </x-filament::button>
        {{ $this->createAction() }}
    </div>
    <div class="bg-white dark:bg-gray-950 rounded-xl ring-1 mine-header">
        <div class="grid grid-cols-12 md:grid-cols-16 gap-4 px-4 py-4 text-sm font-semibold bg-gray-100 text-gray-950 dark:text-gray-200">
            @foreach($columns as $column)
                <div class="{{ $column['class'] ?? 'col-span-3'}} {{ $column['name'] == 'created_at' ? 'hidden md:block': ''   }}">
                    {{ $column['label'] }}
                </div>
            @endforeach
            <div class="col-span-4 text-right">操作</div>
        </div>
        <div
                x-on:expand-all.window="allExpanded = true; $nextTick(() => { document.querySelectorAll('[x-data]').forEach(el => { if(el.__x && el.__x.$data && typeof el.__x.$data.expanded !== 'undefined') el.__x.$data.expanded = true }) })"
                x-on:collapse-all.window="allExpanded = false; $nextTick(() => { document.querySelectorAll('[x-data]').forEach(el => { if(el.__x && el.__x.$data && typeof el.__x.$data.expanded !== 'undefined') el.__x.$data.expanded = false }) })"
            class="divide-y divide-gray-200 dark:divide-gray-700">
            @if($items->isEmpty())
                <div class="px-4 py-6 text-center text-gray-500 dark:text-gray-400">
                    暂无数据
                </div>
            @else
                @foreach($items as $item)
                    <x-resources.tree-table :item="$item" :columns="$columns" :level="0" />
                @endforeach
            @endif
        </div>
    </div>
    <x-filament-actions::modals />
</x-filament-panels::page>